﻿#region << 文件说明 >>

/*----------------------------------------------------------------
 * 命名空间：Vampirewal.ToolCenter.ViewModel
 * 唯一标识：c8150ef7-4674-4713-ac2d-283d59b3454e
 * 文件名：MainViewModel
 *
 * 创建者：杨程
 * 电子邮箱：235160615@qq.com
 * 创建时间：2023/12/26 12:42:22
 * 版本：V1.0.0
 * 描述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时间：
 * 修改说明：
 *
 * 版本：V1.0.1
 *----------------------------------------------------------------*/

#endregion << 文件说明 >>

using CommunityToolkit.Mvvm.Input;
using System.Collections.ObjectModel;
using Vampirewal.Core;
using Vampirewal.Core.Attributes;
using Vampirewal.Core.Interface;
using Vampirewal.Core.SimpleMVVM;
using Vampirewal.ToolCenter.ViewModel.Services;

namespace Vampirewal.ToolCenter.ViewModel;

/// <summary>
///
/// </summary>
[VampirewalIoCRegister("Vampirewal.ToolCenter.ViewModel.MainViewModel")]
public partial class MainViewModel : ViewModelBase
{
    private IVampirewalCoreDialogMessage Dialog { get; set; }

    /// <summary>
    /// 构造函数
    /// </summary>
    public MainViewModel(ILoadPluginService load, IVampirewalCoreDialogMessage dialog)
    {
        Dialog = dialog;

        var config = VampirewalCoreContext.GetInstance().GetOptions<AppBaseOptions>();

        Title = $"{config.AppChineseName}(版本：{config.AppVersion})";

        Plugins = new ObservableCollection<PluginInfoVO>(load.PluginInfoVOs);
    }

    public override void PassData(object obj)
    {
    }

    public ObservableCollection<PluginInfoVO> Plugins { get; set; }

    /// <summary>
    /// 选择插件
    /// </summary>
    /// <param name="plugin"></param>
    [RelayCommand]
    public void SelectedPlugin(PluginInfoVO plugin)
    {
        Dialog.OpenDialogWindow(new Core.WindoSetting.DialogWindowSetting()
        {
            UcView = WindowsManager.GetInstance().GetView(plugin.ViewKey),
            WindowHeight = plugin.Height,
            WindowWidth = plugin.Width,
            IsShowMaxButton = true,
            IsOpenWindowSize = true,
            IsShowMinButton = false,
            IconStr = plugin.PluginIconPath
        });
    }
}